﻿using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System;
namespace Library.WebControls.SimplePaging {
	//[Designer(typeof(SpGridViewDesign))]
	//[SupportsEventValidation]
	//[DesignTimeVisible(true)]
	[ParseChildren(true)]
	[PersistChildren(false)]
	[DefaultProperty("ClientScript")]
	[ToolboxData("<{0}:SpGridView runat=server></{0}:SpGridView>")]
	public class IconControl : Image {
		public IconControl() {
			ClientScript = new ClientScript();
		}
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
		public override string ImageUrl {
			get {
				return base.ImageUrl;
			}
			set {
				base.ImageUrl = value;
			}
		}
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		[Browsable(false)]
		public override string ID {
			get {
				return base.ID;
			}
			set {
				base.ID = value;
			}
		}
		
		[PersistenceMode(PersistenceMode.InnerProperty)]
		[MergableProperty(false)]
		[Category("Data")]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
		[Browsable(false)]
		public ClientScript ClientScript { get; private set; }
		internal string ClientOnClick { get; set; }

		protected override void Render(HtmlTextWriter writer) {
			if (!String.IsNullOrEmpty(ClientScript.Click)) {
				Attributes["onclick"] = ClientScript.Click;
			} else if (!String.IsNullOrEmpty(ClientOnClick) && String.IsNullOrEmpty(Attributes["onclick"])) {
				Attributes["onclick"] = ClientOnClick;
			}
			base.Render(writer);
		}
	}
}
